package patterndemo.mediator;

/**
 * 不适用中介者模式
 */
public abstract class AbstractColleague {

    int number;

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public abstract void setNumber(int number, AbstractColleague colleague);


}

class ColleagueA extends AbstractColleague {

    @Override
    public void setNumber(int number, AbstractColleague colleague) {
        this.number = number;
        colleague.setNumber(number * 100);
    }
}

class ColleaureB extends AbstractColleague {

    @Override
    public void setNumber(int number, AbstractColleague colleague) {
        this.number = number;
        colleague.setNumber(number / 100);
    }
}

class Client {
    public static void main(String[] args) {
        AbstractColleague collA = new ColleagueA();
        AbstractColleague collB = new ColleaureB();

        System.out.println("==========设置A影响B==========");
        collA.setNumber(1288, collB);
        System.out.println("collA的number值："+collA.getNumber());
        System.out.println("collB的number值："+collB.getNumber());

        System.out.println("==========设置B影响A==========");
        collB.setNumber(87635, collA);
        System.out.println("collB的number值："+collB.getNumber());
        System.out.println("collA的number值："+collA.getNumber());
    }
}


